package com.iwdnb.gkgz.common.utils;

import java.math.BigDecimal;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import com.iwdnb.bmnf.common.utils.ClassUtils;

public class MagicVariableUtils {
    private static final String JSON_FILE_PATH = "magicVariable.json";
    private static final JSONObject MAGIC_VARIABLE_MAP;

    static {
        String content = ClassUtils.getFileContentList(JSON_FILE_PATH).get(0);
        MAGIC_VARIABLE_MAP = JSON.parseObject(content);

    }

    public static BigDecimal getMagicVariable(String code, String date) {
        String key = code + ":" + date;
        if (MAGIC_VARIABLE_MAP.containsKey(key)) {
            return MAGIC_VARIABLE_MAP.getBigDecimal(key);
        }
        key = "0:" + date;
        if (MAGIC_VARIABLE_MAP.containsKey(key)) {
            return MAGIC_VARIABLE_MAP.getBigDecimal(key);
        }
        return BigDecimal.ZERO;
    }
}
